﻿@model Zatify.WebUI.Models.BusinessProfileCategoriesViewModel
@{
    ViewBag.Title = "Profile - Categories";
    ViewBag.ContentTitle = "Profile - Categories";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";
}
@section Scripts
{
    <script type="text/javascript">

        var catsIds = [];

        $(document).ready(function () {

            catsIds = $("#categoriesIds").val().split(",");

            $("#btnDeleteCategoires").click(function () {

                if (confirm("Are you sure to delete selected categories ?")) {
                    $("#formCategories").submit();
                }
                else {
                    return;
                }
            });
        });

        function CancelCategoryId(categoryId) {

            $("#btnMinus_" + categoryId).hide();
            $("#btnCross_" + categoryId).show();

            catsIds.push(categoryId);

            $("#categoriesIds").val(catsIds.join(","));
        }

        function RemoveCategoryId(categoryId) {

            $("#btnCross_" + categoryId).hide();
            $("#btnMinus_" + categoryId).show();

            catsIds = jQuery.grep(catsIds, function (value) {
                return value != categoryId;
            });

            $("#categoriesIds").val(catsIds.join(","));
        }

    </script>
}
<div class="business_interface_area">
    <div class="business_profile_categories">
        @using (Html.BeginForm("CategoriesRemove", "BusinessProfile", FormMethod.Post, new { id = "formCategories" }))
        {
            @Html.Hidden("categoriesIds", Model.SelectegCategoriesIds)
        }
        @foreach (var cat in Model.SelectedCategories)
        {
            <div class="categories_line category_navbar">
                <label>
                    @Html.CategoryBreadCrumbsSeparated(cat, x => Url.Action("", "", new { categoryId = x }))
                    <a id="btnCross_@(cat.CategoryId)" class="cross_btn" onclick="RemoveCategoryId(@cat.CategoryId)" href="#" style="display: inline;">
                        <img class="category_control" alt="" src="@Url.Content("~/Content/zatify/images/cross_btn.png")" />
                    </a><a id="btnMinus_@(cat.CategoryId)" class="minus_btn" onclick="CancelCategoryId(@cat.CategoryId)" href="#" style="display: none;">
                        <img class="category_control" alt="" src="@Url.Content("~/Content/zatify/images/minus_btn.png")" />
                    </a>
                </label>
            </div>
        }
        <div class="category_add_rem_btn">
            <a href="@Url.Action("Categories", "BusinessProfile")">
                <img alt="" src="@Url.Content("~/Content/zatify/images/ad_categories_btn.png")" /></a>
            <a id="btnDeleteCategoires" href="#">
                <img alt="" src="@Url.Content("~/Content/zatify/images/remove_categories_btn.png")" style="margin-left: 40px;" /></a>
        </div>
        @*<input type="submit" value="Save" class="blue_btn" style="margin-left: 0px; margin-top: 30px;" />*@
    </div>
    <div class="clearfix">
    </div>
</div>
